using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter19
{
	/// <summary>
	/// Example07: Heating a Spray Can
	/// A spray can containing a propellant gas at twice 
	/// atmospheric pressure (202 kPa) and having a volume
	/// of 125.00 cm^3 is at 22 C. It is then tossed into an
	/// open fire. When the temperature of the gas is the can 
	/// reaches 195 C, what is the pressure inside the can?
	/// Assume any change in the volume of the can is negligible.
	/// P_f = 320 kPa.
	/// </summary>
	public class Example07
	{
		public Example07()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Temperature t1 = new L.Temperature();
			t1.C = 22.0;
			t1.FindAbsoluteFromCelsius();

			L.Volume v1 = new L.Volume();
			v1.mCUBE = 125.0*1.0E-6;  

			L.Pressure p1 = new L.Pressure();
			p1.Pa = 202.0E3;

			L.Temperature t2 = new L.Temperature();
			t2.C = 195.0;
			t2.FindAbsoluteFromCelsius();
		
			L.Volume v2 = new L.Volume();
			v2.mCUBE = 125.0*1.0E-6;  

			L.Pressure p2 = new L.Pressure();
			p2.Pa = p1.Pa*v1.mCUBE/t1.K*t2.K/v2.mCUBE;
			
			result+=Convert.ToString(p2.Pa);    
		}
	}
}
